package com.rerun.controller.base;

import com.baomidou.mybatisplus.mapper.EntityWrapper;
import com.rerun.common.anno.Log;
import com.rerun.common.bean.Rest;
import com.rerun.common.controller.SuperController;
import com.rerun.entity.JobTag;
import com.rerun.service.JobTagService;

import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.List;

/**
 * 职位标签
 */
@Api(value="职位标签",description="职位标签")
@Controller
@RequestMapping("/jobTag")
public class JobTagController extends SuperController{
	@Autowired
    private JobTagService JobTagService;
	
	/**
	 * 添加页面
	 */
	@RequestMapping("/addJobTagPage")
	public String addPage(){
		
		return "business/jobTag/add";
	}
	/**
	 * 标签添加
	 * 
	 */

	@RequestMapping(value="/addJobTag")
	@ResponseBody
	public Rest add(JobTag jobTag){
		JobTagService.insertAllColumn(jobTag);
		return Rest.ok();
	}
	
	/**
	 *标签展示
	 */
	@ApiOperation(value = "标签展示", notes = "标签展示", httpMethod = "GET")
	@RequestMapping(value="/showJobTag")
	
	public String show(Model model){
		EntityWrapper<JobTag > wrapper=new EntityWrapper<JobTag>();
	
		 List<JobTag> data = JobTagService.selectList(wrapper);
		 model.addAttribute("list", data);
		return "business/jobTag/list";
	}
	/**
	 * 删除标签
	 */
	@RequestMapping(value="/deleteJobTag")
	@ResponseBody
	public Rest delete(String id){
		JobTagService.deleteById(id);
    	return Rest.ok();
	}
	 /**
     * 批量删除标签
     *
     * @param ids the ids
     * @return the rest
     */
    @Log("批量删除")
    @RequestMapping("/delete/{ids}")  
    @ResponseBody
    public Rest deleteBatch(@RequestParam("id[]") List<String> ids){
    	JobTagService.deleteBatchIds(ids);
    	return Rest.ok();
    }
}
